package com.demo.spring.annoinit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StudentServiceImpl implements StudentService {
	
	public StudentServiceImpl() {
		System.out.println("StudentServiceImpl");
	}

	@Autowired(required = false)
	private TeacherService teacherService;

	//@Autowired
	//public StudentServiceImpl(TeacherService teacherService) {
		//super();
		//this.teacherService = teacherService;
	//}

	@Override
	public void play() {
		if(teacherService != null) {
			teacherService.teach();
		}
		System.out.println("student play!");
	}

}
